import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data.dart';
import 'package:provider/provider.dart';

class B2PageWidget extends StatefulWidget {
  const B2PageWidget({super.key});

  @override
  State<B2PageWidget> createState() => _B2PageWidgetState();
}

class _B2PageWidgetState extends State<B2PageWidget> {
  @override
  Widget build(BuildContext context) {
    //Provider.of 所在的 Widget 会被重建  listen: true
    ShareData e = Provider.of<ShareData>(context, listen: true);

    return Column(
      children: [
        Text("${e.nickname}"),
        SizedBox(
          height: 20,
        ),
        ElevatedButton(
          onPressed: () {
            e.setNickname("我被B改了");
          },
          child: Text("B页面:更改nickname的值"),
        ),
        SizedBox(
          height: 20,
        ),
      ],
    );
  }
}
